/**
 * 
 */
package com.eis.persist.model.function;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.eis.persist.model.base.BasePersist;
import com.eis.persist.model.bizsystem.PersistBizSystem;
import com.eis.persist.model.bizsystem.PersistConnectorConfigure;



/**
 * @author panwei01
 *
 */
public class PersistFunction extends BasePersist implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8035273361662183602L;

	public PersistFunction() {
		super();
	}
	
	public PersistFunction(Map<String, Object> record) {
		super(record);
		this.id = (Integer) record.get("id");
		this.functionID = (String) record.get("functionID");
		this.functionDisplayName = (String) record.get("functionDisplayName");
		this.isActive = ((Integer) record.get("isActive") != 0);
		PersistBizSystem bizSystem = new PersistBizSystem();
		this.bizSystem = bizSystem;
		bizSystem.setId((Integer) record.get("bizsysId"));
		bizSystem.setName((String) record.get("bizsysName"));
		bizSystem.setConnectorStaticsClassName((String) record.get("connectorStaticsClassName"));
		
		if (record.get("bizsysConnectorConfig") != null && (Integer) record.get("bizsysConnectorConfig") > 0) {
			PersistConnectorConfigure connectorConfig = new PersistConnectorConfigure();
			this.connectorConfig = connectorConfig;
			connectorConfig.setId((Integer) record.get("bizsysConnectorConfig"));
			connectorConfig.setConfigXml((String) record.get("configXml"));
			connectorConfig.setName((String) record.get("configName"));
			connectorConfig.setBizSystem(bizSystem);
		}
		
		
		this.lastDataFetchTime = (Date) record.get("lastDataFetchTime");
		this.sapserveradd = (String) record.get("sapserveradd");
		this.sysId = (Integer) (record.get("sysId") != null ? record.get("sysId") : 0);
		// this.instenceNum = (Integer) record.get("instenceNum");
		this.clientId = (Integer) (record.get("clientId") != null ? record.get("clientId") : 0);
		this.datafetchID = (String) record.get("datafetchID");
		this.functionSchema = new ArrayList<PersistFunctionSchema>();
		this.functionParameter = new ArrayList<PersistFunctionParameter>();
		this.dataUniqueKey = ((String) record.get("data_unique_key")).split(",");
		
		this.functionType = new PersistFunctionType();
		this.functionType.setId((Integer) record.get("typeId"));
		this.functionType.setTypeName((String) record.get("typeName"));
		this.functionType.setDisplayName((String) record.get("DisplayName"));
	}
	
	private int id;
	private String functionID;
	private String functionDisplayName;
	private Boolean isActive;
	private String datafetchID;
	private Date lastDataFetchTime;
	private String sapserveradd;
	private int sysId;
	private int instenceNum;
	private int clientId;
	private List<PersistFunctionSchema> functionSchema;
	private List<PersistFunctionParameter> functionParameter;
	private String[] dataUniqueKey;
	private PersistFunctionType functionType;
	private PersistBizSystem bizSystem;
	private PersistConnectorConfigure connectorConfig;

	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getFunctionID() {
		return functionID;
	}
	public void setFunctionID(String functionID) {
		this.functionID = functionID;
	}
	public String getFunctionDisplayName() {
		return functionDisplayName;
	}
	public void setFunctionDisplayName(String functionDisplayName) {
		this.functionDisplayName = functionDisplayName;
	}
	public Boolean isActive() {
		return isActive;
	}
	public void setActive(Boolean isActive) {
		this.isActive = isActive;
	}
	public String getDatafetchID() {
		return datafetchID;
	}
	public void setDatafetchID(String datafetchID) {
		this.datafetchID = datafetchID;
	}
	public Date getLastDataFetchTime() {
		return lastDataFetchTime;
	}
	public void setLastDataFetchTime(Date lastDataFetchTime) {
		this.lastDataFetchTime = lastDataFetchTime;
	}
	public String getSapserveradd() {
		return sapserveradd;
	}
	public void setSapserveradd(String sapserveradd) {
		this.sapserveradd = sapserveradd;
	}
	public int getSysId() {
		return sysId;
	}
	public void setSysId(int sysId) {
		this.sysId = sysId;
	}
	public int getInstenceNum() {
		return instenceNum;
	}
	public void setInstenceNum(int instenceNum) {
		this.instenceNum = instenceNum;
	}
	public int getClientId() {
		return clientId;
	}
	public void setClientId(int clientId) {
		this.clientId = clientId;
	}

	public List<PersistFunctionSchema> getFunctionSchema() {
		return functionSchema;
	}

	public void setFunctionSchema(List<PersistFunctionSchema> persistFunctionSchema) {
		this.functionSchema = persistFunctionSchema;
	}

	public List<PersistFunctionParameter> getFunctionParameter() {
		return functionParameter;
	}

	public void setFunctionParameter(List<PersistFunctionParameter> persistFunctionParameter) {
		this.functionParameter = persistFunctionParameter;
	}

	public String[] getDataUniqueKey() {
		return dataUniqueKey;
	}

	public void setDataUniqueKey(String[] dataUniqueKey) {
		this.dataUniqueKey = dataUniqueKey;
	}

	public PersistFunctionType getFunctionType() {
		return functionType;
	}

	public void setFunctionType(PersistFunctionType persistFunctionType) {
		this.functionType = persistFunctionType;
	}

	public PersistBizSystem getBizSystem() {
		return bizSystem;
	}

	public void setBizSystem(PersistBizSystem bizSystem) {
		this.bizSystem = bizSystem;
	}

	public PersistConnectorConfigure getConnectorConfig() {
		return connectorConfig;
	}

	public void setConnectorConfig(PersistConnectorConfigure connectorConfig) {
		this.connectorConfig = connectorConfig;
	}
}